Skip to content

Conversation

@kkartunov
Copy link
Contributor

Potential fix for https://github.com/topcoder-platform/challenge-api-v6/security/code-scanning/72

The best way to fix this problem is to ensure that all occurrences of the pipe character (|) in the suspiciousReason string are replaced with " & ". This can be achieved by using a regular expression with the global flag (/g), specifically .replace(/\|/g, ' & '), so that every pipe in the string is replaced—not just the first. Only line 178 needs to be changed, and no additional imports or method definitions are required.


Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…ing or encoding

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@kkartunov kkartunov requested a review from jmgasper November 4, 2025 08:04
@kkartunov kkartunov marked this pull request as ready for review November 4, 2025 08:05
if (suspiciousReason) {
if (invalidDateBehavior.warn) {
console.warn(`${fileName}: record ${recordIdentifier} has ${suspiciousReason.replace('|', ' & ')} (${parsedDate.toISOString()}); strategy=${invalidDateBehavior.strategy}`);
console.warn(`${fileName}: record ${recordIdentifier} has ${suspiciousReason.replace(/\|/g, ' & ')} (${parsedDate.toISOString()}); strategy=${invalidDateBehavior.strategy}`);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The use of suspiciousReason.replace(/\|/g, ' & ') correctly replaces all occurrences of the pipe character. Ensure that suspiciousReason is always a string to avoid runtime errors. Consider adding a check or conversion to string if there's any chance suspiciousReason could be non-string.

@kkartunov
Copy link
Contributor Author

@jmgasper looks safe to merge this PR which will close the severity alert.

@kkartunov kkartunov merged commit 29ae9d7 into develop Nov 5, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants